package gov.nasa.anml.lifted;

import java.util.ArrayList;

import gov.nasa.anml.*;
import gov.nasa.anml.utility.*;

// really this is a function binding

public abstract class Bind<S,T,V extends SimpleObject<? super V>> extends ExpressionImp<T,V> {
	public S ref;
	public ArrayList<Expression<? extends SimpleObject<?>,?>> arguments = new ArrayList<Expression<? extends SimpleObject<?>,?>>();

	protected SimpleObject<?>[] args; // cut down on memory bloat
	
	public Bind() {}

	public Bind(S ref) {
		this.ref=ref;
	}
	
	public void addArgument(Expression<? extends SimpleObject<?>,?> p) {
		arguments.add(p);
	}
	
	public void init() {
		args = new SimpleObject[arguments.size()];
	}
	
	protected final SimpleObject<?>[] setArgs(State s) {
		int i=0;
		for (Expression<? extends SimpleObject<?>,?> e : arguments) {
			args[i++] = e.value(s);
		}
		return args;
	}
	
}


